/*
 * Host.java
 *
 * Created on June 13, 2006, 8:52 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hubsniffer.util;

import java.net.InetAddress;
import java.net.UnknownHostException;
import libjdc.dc.log.Log;

/**
 *
 * @author root
 */
public class Host {
    
    private static String hostip = null;
    
    public static String getHostIP(){
        try {
            return (hostip==null)? InetAddress.getByName("sghdc.no-ip.org").getHostAddress():hostip;
        } catch (UnknownHostException ex) {
            ex.printStackTrace(Log.err);
            return "127.0.0.1";
        }
    }

    public String getHostip() {
        return hostip;
    }
    
    public static boolean isIP(String ip){
        return ip.matches("[1-9][0-9]*.[1-9][0-9]*.[1-9][0-9]*.[1-9][0-9]*(:[0-9]*)?");
    }
    
}
